#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <linux/fb.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "font_manager.h"
#include "disp_manager.h"



int main(int argc, char **argv)
{
	 fontbitmap Fontbitmap;
	  char *string="asdkjhhhhhhh___123**(0)";
	 int i = 0;
	 int LCD_x;int LCD_y;
	int fontsize;
	DispBuff_p getdispbuff;


int error;



	
	 if(argc != 5)
	 {
		printf("Usaged:\n");
	 	printf("%s <fontfile> <x> <y> <fontsize>\n", argv[0]);

	 }
	 LCD_x=atoi(argv[2]);
	 LCD_y=atoi(argv[3]);
	 fontsize=atoi(argv[4]);


	 
	DisplayInit();
	error = selectdefaulterDisplay("fb");
	if(error)
	{
		printf("selectdefaulterDisplay\n");

	}
	error =initdefaulterDisplay();
		if(error)
	{
		printf("selectdefaulterDisplay\n");

	}
	getdispbuff =  get_initdisbuffer();

	FontlibInit();
	error =selectdefaulterFontlib("freetype");
	if(error)
	{
		printf("selectdefaulterDisplay\n");

	}
	error =initdefaulterFontlib(argv[1]);
	if(error)
	{
		printf("selectdefaulterDisplay\n");

	}

	SetFontSize(fontsize);

	
	lcd_clear();
	
	
	while(string[i])
	{

		
		/*获得位图*/
		Fontbitmap.CurOrigin_x = LCD_x;
		Fontbitmap.CurOrigin_y = LCD_y;
		if(GetFontBitMap(string[i], &Fontbitmap))
		{
			printf("GetFontBitMap error \n");

		}

		/*画到buff*/
		DrawFontBitMap(&Fontbitmap, 0xff00ff);



		/*buff刷到屏幕*/
		FlushDisplayRegion(&Fontbitmap.tRegion, *getdispbuff);

		
		LCD_x = Fontbitmap.NexOrigin_x;
		LCD_y = Fontbitmap.NexOrigin_y;

		i++;

		
	}
	
	return 0;	
}

